package duanxin;


public class DingShiQi_01 {
    /** 
     * 普通thread 
     * 这是最常见的，创建一个thread，然后让它在while循环里一直运行着， 
     * 通过sleep方法来达到定时任务的效果。这样可以快速简单的实现，代码如下： 
     * @author GT 
     * 
     */  
	
	private boolean temp=true;
	private final long timeInterval = 60000;  
	
    public boolean isTemp() {
		return temp;
	}

	public void setTemp(boolean temp) {
		this.temp = temp;
	}
	private int number=3;
		public void dingshiqi_01(final String phone) { 
            // run in a second
			System.out.println("phonephone"+phone);
            Runnable runnable = new Runnable() {  
                public void run() { 
                	int a =1;
                	
                	long currentTimeMillis = System.currentTimeMillis();
                	
                	 System.out.println("一分钟前 !!");
                    while (temp) {  
                        // ------- code for task to run
                    	if(a==2){
                     System.out.println("一分钟后 !!");
                       
                     SendMsg_webchinese s=new SendMsg_webchinese();
                     
                     
                     long currentTimeMillis2 = System.currentTimeMillis();
                     System.out.println("延长时间："+(currentTimeMillis2-currentTimeMillis));
                     try {
						s.SendMessage(phone);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
                    	
                    	}
                        // ------- ends here  
                        try {  
                            Thread.sleep(timeInterval);  
                        } catch (InterruptedException e) {  
                            e.printStackTrace();  
                        }  
                        a=a+1;
                       
                        if(a>=number){
                        	
                        	temp=false;
                        }
                    }  
                }  
            };  
            Thread thread = new Thread(runnable);  
            thread.start();  
        }  
		
	/*	public static void main(String[] args) {
			DingShiQi_01 ds = new DingShiQi_01();
			ds.dingshiqi_01(String);
		}*/
}
